@echo off

SET LIB=jpgbmp
SET CFLG=-D___SYS_I486 -D___OS_WIN
SET GFLG=-D___GUI
SET OBJS=std.c jpeg1.c jpeg2.c bmp.c
SET OBJS=%OBJS% huf.c dct.c
SET LIBS=

IF "%1" EQU "-g" (
  SET CFLG=%CFLG% %GFLG%
  shift
)
IF "%1" EQU "-ropt" (
  SET CFLG=%CFLG% -D___ROPT
  shift
)

echo CFLG=%CFLG%
gcc -s -O2 -Wall -c %CFLG% %OBJS% & ar -r lib%LIB%.a *.o

dlltool --output-def %LIB%.def --export-all-symbols lib%LIB%.a
dlltool --output-lib lib%LIB%-dll.a --input-def %LIB%.def --dllname %LIB%.dll
dllwrap -o %LIB%.dll --def %LIB%.def lib%LIB%.a %LIBS%
pexports %LIB%.dll >%LIB%-check.def
